package CSDN;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 王圆豪
 * Date: 2025-05-08
 * Time: 23:46
 */
public class Test18 {
    public static void main(String[] args) {
        Object l = new Object();
        Thread t1 = new Thread(()->{
            synchronized (l) {
                try {
                    Thread.sleep(1000);
                    System.out.println("线程等待中......");
                    l.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });

        Thread t2 = new Thread(()->{
            System.out.println("尝试唤醒线程......");
            synchronized (l) {
                l.notify();
            }
        });
        t1.start();
        t2.start();
    }
}
